package net.lzzy.practicesapi1.services;

import net.lzzy.practicesapi1.entities.User;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.UUID;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
class UserServiceTest {
    @Autowired
    private UserService service;

    @Test
    void get() {
        assertEquals(3, service.get().size());//4df47382-95fc-4e3f-b165-6d2f834a8408
        System.out.println(service.get().get(1).getId());//4a99828a-c09b-4979-a298-2dc1dae11b85
        assertEquals("lisi", service.get().get(0).getUserName());
    }

    @Test
    void testGet() {
        assertEquals(1,service.get(0,1).size());
        assertEquals(2,service.get(0,2).size());
    }

    @Test
    void count() {
        assertEquals(3,service.count());
    }

    @Test
    void search() {
        assertEquals(1,service.search("9842").size());
        assertEquals(1,service.search("denglaoshi").size());
        assertEquals(1,service.search("李四").size());
    }

    @Test
    void getApplyTeacher() {
        assertEquals(3,service.getApplyTeacher(false).size());
        assertEquals(3,service.getApplyTeacher(false).size());
    }

    @Test
    void approveTeacher() {
        UUID id = UUID.fromString("`4a99828a-c09b-4979-a298-2dc1dae11b85`");
        User denglaoshi = service.approveTeacher(id);
        assertEquals(1,denglaoshi.getType());
        assertFalse(denglaoshi.isApplyTeacher());
    }

    @Test
    void declineTeacher() {
        UUID id = UUID.fromString("4df47382-95fc-4e3f-b165-6d2f834a8408");
        User lisi = service.declineTeacher(id);
        assertEquals(2,lisi.getType());
        assertFalse(lisi.isApplyTeacher());
    }

    @Test
    void banUser() {
    }
}